<?php
if (!isset($modoBusqueda) || !$modoBusqueda){
    $contextMenu[0]["link"]      = "javascript:fn_nuevo()";
    $contextMenu[0]["linkIcon"]  = "application_add.png";
    $contextMenu[0]["linkTitle"] = "Nueva orden";
}?>
<script>

fn_guardar = function ()
{
	var guardar = confirm("Desea guardar los datos...?")
    if ( guardar ) 
    {
		  var str=$("#form_nuevo").serialize();
			$.ajax({
				url:'/gourmet-express/trunk/src/index.php?do=ImTransfer&accion=guardarSave',
				data:str,
				type:'get',
				dataType: "json",
				success:function (data){
				        if(data.rpta=='true')
				        {
					          //listarTransferencias();
                                                  fn_editar(data.transferId);
				        }else{
				            alert(data.msg);
				        }
						}
				   });
     }
};

fn_actualizar =function(){
	var actualizar = confirm("Desea guardar los datos...?")
	if ( actualizar ) {
  	var str=$("#form_editar").serialize();
  	$.ajax({
  		url:'/gourmet-express/trunk/src/index.php?do=ImTransfer&accion=editarSave',
  		data:str,
  		type:'get',
  		dataType: "json",
  				success:function (data){
  				        if(data.rpta=='true')
  				        {
  					          //listarTransferencias();
                                                  fn_editar(data.transferId);
  				        }else{
  				            alert(data.msg);
  				        }
  						}
  				   });
	}
 };

fn_nuevo=function (){
	$("#zonaContenedor").load("/gourmet-express/trunk/src/index.php?do=ImTransfer&accion=nuevo", function(){
	
	});
}; 

		
fn_editar=function (s_TransferId){			
		   $("#zonaContenedor").load("/gourmet-express/trunk/src/index.php?do=ImTransfer&accion=editar&s_TransferId="+s_TransferId, function(){
		   	
		   });
 }

fn_cerrar =function(){
	var actualizar = confirm("Desea transferir el stock ?")
	if ( actualizar ) {
         var str=$("#form_editar").serialize();
         $.ajax({
              url:'/gourmet-express/trunk/src/index.php?do=ImTransfer&accion=cerrar',
              data:str,
              type:'get',
              dataType: "json",
                        success:function (data){
                                if(data.rpta=='true')
                                {
                                    fn_editar(data.s_TransferId);   
                                }else{
                                    alert(data.msg);
                                }
                       }
          });
	}
 };



 fn_detalle = function fn_detalle(s_TransferId){			
		   $("#zonaContenedor").load("/gourmet-express/trunk/src/index.php?do=ImTransfer&accion=shw&s_TransferId="+s_TransferId, function(){
		   	
		   });
 }
  
</script>
<body>
<div id="main">
  <?php include $_SERVER['DOCUMENT_ROOT'].'/gourmet-express/trunk/src/views/header.inc'; ?>
  <div id="zonaContenedor">
    <h3>.:: Transferencias </h3>
    <div>

	<form id='formTransf' name='formTransf' method="post" >    
		Transferencia Nro : <input type="text" name="s_TransferId" size="15" value="">
		Doc Transfer : <input type="text" name="s_DocTransfer" size="15" value="">  
		Doc Ref : <input type="text" name="s_DocRef" size="15" value="">
		<input type="submit" name="aceptar" value="aceptar" >    
	</form>         
		
		<table id="flex1" style="display:none"></table>
		<script type="text/javascript">
		$("#flex1").flexigrid({
			url: '/gourmet-express/trunk/src/index.php?do=ImTransfer&accion=contenedor',
			dataType: 'json',
			colModel : [
				{display: 'TransferId', name : 's_TransferId', width : 100, sortable : true, align: 'left'},
				{display: 'Doc Transfer', name : 's_DocTransfer', width : 80, sortable : true, align: 'left'},
				{display: 'Doc Ref', name : 's_DocRef', width : 80, sortable : true, align: 'left'},
				{display: 'Tipo Transfer', name : 's_TipoTransfer', width : 80, sortable : true, align: 'left'},
				{display: 'Estado', name : 's_Estado', width : 60, sortable : true, align: 'left'},
				{display: 'Alm OrigenId', name : 's_AlmOrigenId', width : 80, sortable : true, align: 'left'},
				{display: 'Alm DestinoId', name : 's_AlmDestinoId', width : 80, sortable : true, align: 'left'},
				{display: 'Crea Fecha', name : 's_CreaFecha', width : 60, sortable : true, align: 'left'},
				{display: '&nbsp;', name : 'opciones', width : 60, sortable : true, align: 'right'}
				],							
				
			searchitems : [
				{display: 's_TransferId', name : 'soId'}				
				],
			sortname: "s_TransferId",
			sortorder: "asc",
			usepager: true,
			title: 'Transferencias',
			useRp: true,
			rp: 15,
			showTableToggleBtn: true,
			width: 800,
			onSubmit: addFormData,
			height: 270
		});   
		
		
		//This function adds paramaters to the post of flexigrid. You can add a verification as well by return to false if you don't want flexigrid to submit			
		function addFormData(){
			//passing a form object to serializeArray will get the valid data from all the objects, but, if the you pass a non-form object, you have to specify the input elements that the data will come from
			var dt = $('#formTransf').serializeArray();
			$("#flex1").flexOptions({params: dt});
			return true;
		}
			
		$('#formTransf').submit(function (){
			$('#flex1').flexOptions({newp: 1}).flexReload();
			return false;
		});
		</script>
	</div>
	<div id="div_listar" align="center"></div>
	<div id="div_oculto" style="display: none;"></div>
    
    </div>
</div>
</body>
<script>
//fn_buscar();
</script>